<?
// Define host, user, pass, database in the config.php at models

class sql 
{
	// Hàm kết nối CSDL
	public function CONNECT_DB($host,$user,$pass,$db) {
		
		$conn = mysql_connect($host,$user,$pass);
		// Kết nối
		mysql_query("SET NAMES 'utf8'",$conn);
		if(!$conn) {
			die(mysql_error());
			return false;
		}
		else {
			mysql_select_db($db,$conn);			
		}		
	}
	// Hàm truy vấn dữ liệu
	public function query($string) {		
		return mysql_query($string); 
	}	
	// Kiểm tra số dòng
	public function num_rows($num) { 
		return mysql_num_rows($num); 
	}		
	
	public function fetch_array($arr) { 
		return mysql_fetch_array($arr); 
	}	
	public function fetch_object($arr) { 
		return mysql_fetch_object($arr); 
	}		
	public function free_result($result) { 
		return mysql_free_result($result); 
	}
	
	
}

?>